#pragma once
#include <list>
#include <memory>

class ListTran {
  public:
  template <typename T, typename C>
  static std::shared_ptr<std::list<C>> tran_class(std::shared_ptr<std::list<T>> oldClass) {
    std::shared_ptr<std::list<C>> newClass = std::shared_ptr<std::list<C>>();
    for (auto it: *oldClass) {
      newClass->push_back(dynamic_cast<C>(it));
    }
    return newClass;
  }

  template <typename T, typename C>
  static std::shared_ptr<std::list<std::shared_ptr<C>>> tran_class(std::shared_ptr<std::list<std::shared_ptr<T>>> oldClass) {
    std::shared_ptr<std::list<std::shared_ptr<C>>> newClass = std::shared_ptr<std::list<std::shared_ptr<C>>>();
    for (auto it: *oldClass) {
      newClass->push_back(std::dynamic_pointer_cast<C>(it));
    }
    return newClass;
  }
};